<template>
    <div class="Item">
        <div>{{ props.title }}</div>
        <a-space class="content" :size="8">
            <div class="content2" v-for="(url, index) in imgUrls">
                <img class="img" :src="url" @click="actions.clickImg(index)" />
                <div>{{ imgNames[index] }}</div>
            </div>
        </a-space>
        <div class="line"></div>
    </div>
</template>

<script setup>
    const props = defineProps({
        title: { type: String, default: '', required: false },
        imgUrls: { type: Array, default: [], required: false },
        imgNames: { type: Array, default: [], required: false }
    });

    const emit = defineEmits(['clickImg']);

    const actions = {
        clickImg(index) {
            emit('clickImg', props.title, props.imgNames[index]);
        }
    };
</script>

<style lang="scss" scoped>
    .Item {
        width: 100%;
        display: flex;
        flex-direction: column;
        padding: 4px;

        .content {
            width: 100%;

            .content2 {
                flex: 1;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                cursor: pointer;
            }

            .img {
                width: 70px;
                height: 70px;
                border: 1px solid gray;
                border-radius: 5px;
            }
        }

        .line {
            margin-top: 5px;
            width: 100%;
            height: 1px;
            background-color: gray;
        }
    }
</style>
